﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security;
using System.Security.Cryptography;

namespace iHub.App_Code
{
    class SecureRandom
    {
        public int GenerateNumber()
        {
            int val = 0;
            RNGCryptoServiceProvider random = new RNGCryptoServiceProvider("testo");
            byte[] randomBytes = new byte[256 * sizeof(int)];
            random.GetBytes(randomBytes);
            val = BitConverter.ToInt32(randomBytes, GenerateSeed()*4);
            val &= 0x7fffffff;

            return val;
        }

        public int GenerateSeed()
        {
            int value = 0;

            Random random = new Random();
            value = random.Next(0, 255);
 
            return value;
        }
    }
}
